# -*- coding:utf-8 -*-
# 装饰器2

def deco(type):
    print('I got an param Type %d' % type)

    def decoParamLogin(func):
        def logic(*args, **kwargs):
            print('我处理了其他逻辑')
            res = func(*args, **kwargs)
            return res

        return logic

    return decoParamLogin


@deco(type=1)
def test(name):
    print('I am in test and my name is %s' % name)

test('GC')

'''
@deco 等效于 test = deco(func) = decoParamLogin
@deco(type=1) 等效于 test = (deco(type))(func) = decoParamLogin(func) = logic
'''

'''
装饰器存在一个问题（也不能叫做问题）
在执行目标函数之前（test）,就已经隐式运行了装饰器代码(deco())
'''